<?php

namespace yiike\store\models;

use Yii;
use \yiike\store\models\base\GoodsCategory as BaseGoodsCategory;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "ims_ttyc_goods_category".
 */
class GoodsCategory extends BaseGoodsCategory
{

    public function behaviors()
    {
        return ArrayHelper::merge(
            parent::behaviors(),
            [
                # custom behaviors
            ]
        );
    }

    public function rules()
    {
        return ArrayHelper::merge(
            parent::rules(),
            [
                # custom validation rules
            ]
        );
    }

    public static function select_option() {
        $data = self::find(['parent_id' => 0])->orderBy('orderby asc')->asArray(['id', 'name', 'logo'])->all();
        foreach ($data as &$c) {
            $c['items'] = self::find(['parent_id' => $c['id']])->orderBy('orderby asc')->asArray(['id', 'name', 'logo'])->all();
        }
        return $data;
    }
}
